package cn.rdq.iknessplatform.controller;

import cn.rdq.api.dto.DramaCommentDto;
import cn.rdq.api.po.DramaComment;
import cn.rdq.common.CommonResult;
import cn.rdq.iknessplatform.service.DramaCommentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/drama-comment")
@Api
public class DramaCommentController {

    @Autowired
    private DramaCommentService dramaCommentService;

    @GetMapping("/replys")
    public CommonResult getReplys(Long rootParentId) {
        List<DramaCommentDto> dramaCommentDtos = dramaCommentService.listReplys(rootParentId);
        return CommonResult.successObj(dramaCommentDtos);
    }

    @GetMapping("/list")
    public CommonResult comments(Long dramaId) {
        List<DramaCommentDto> dramaCommentDtos = dramaCommentService.listRootComment(dramaId);
        return CommonResult.successObj(dramaCommentDtos);
    }

    @PostMapping("/commit")
    public CommonResult commit(@RequestBody DramaComment dramaComment) {
        dramaCommentService.save(dramaComment);
        return CommonResult.success();
    }

}
